package com.eimf.saf.base.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Controller;

/**
 * @author eden
 * @date 2013-11-13 下午3:11:18
 * @Description: TODO(这里用一句话描述这个类的作用)
 */
@Controller
public class SpringContext implements ApplicationContextAware
{

    private static ApplicationContext context;

    /*
     * 注入ApplicationContext
     */
    @Override
    public void setApplicationContext(final ApplicationContext context) throws BeansException
    {
        // 在加载Spring时自动获得context
        SpringContext.context = context;
    }

    public static Object getBean(final String beanName)
    {
        return SpringContext.context.getBean(beanName);
    }
}
